/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.ivanbiz.report;

import java.util.HashMap;
import java.util.Map;
import net.sf.jasperreports.engine.JasperExportManager;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrintManager;

/**
 *
 * @author Aprisma
 */
public class Report {

    Koneksi koneksi = new Koneksi();
    String fileName = "E:/trunk/BergunaJaya/report/";
    String tujuan = "E:/trunk/BergunaJaya/report/";
    private String noNota;
    private String tanggalAwal;
    private String tanggalAkhir;

    public String getNoNota() {
        return noNota;
    }

    public void setNoNota(String noNota) {
        this.noNota = noNota;
    }

    public String getTanggalAkhir() {
        return tanggalAkhir;
    }

    public void setTanggalAkhir(String tanggalAkhir) {
        this.tanggalAkhir = tanggalAkhir;
    }

    public String getTanggalAwal() {
        return tanggalAwal;
    }

    public void setTanggalAwal(String tanggalAwal) {
        this.tanggalAwal = tanggalAwal;
    }

    public void reportPenjualanByNotaTunai() {
        Map map = new HashMap();
        map.put("KODE", this.getNoNota());
        try {
            //JasperCompileManager.compileReportToFile(fileName + "ReportPenjualanByNotaTunai.jrxml");
            JasperFillManager.fillReportToFile(fileName + "ReportPenjualanByNotaTunai.jasper", map, koneksi.getConnect());
            //JasperExportManager.exportReportToPdfFile(fileName+"penjualan.jrprint");
            JasperPrintManager.printReport(fileName + "ReportPenjualanByNotaTunai.jrprint", true);
            //JasperRunManager.runReportToPdfFile(fileName + "ReportPenjualanByNota.jrprint", map, Koneksi.getConnect());
            //JasperViewer.viewReport(fileName + "ReportPenjualanByNota.jrprint", false);
           // JRTextExporterParameter.
        } catch (Exception e1) {
            e1.printStackTrace();
        } finally {
            koneksi.closeConnection();
        }
    }

    public void reportPenjualanByNotaKredit() {
        Map map = new HashMap();
        map.put("KODE", this.getNoNota());
        try {
            //JasperCompileManager.compileReportToFile(fileName + "ReportPenjualanByNotaKredit.jrxml");
            JasperFillManager.fillReportToFile(fileName + "ReportPenjualanByNotaKredit.jasper", map, koneksi.getConnect());
            //JasperExportManager.exportReportToPdfFile(fileName+"penjualan.jrprint");
            JasperPrintManager.printReport(fileName + "ReportPenjualanByNotaKredit.jrprint", true);
        //JasperRunManager.runReportToPdfFile(fileName + "ReportPenjualanByNota.jrprint", map, Koneksi.getConnect());
        //JasperViewer.viewReport(fileName + "ReportPenjualanByNota.jrprint", false);
        } catch (Exception e1) {
            e1.printStackTrace();
        } finally {
            koneksi.closeConnection();
        }
    }

    public void reportPenjualanByTanggal() {
        Map map = new HashMap();
        map.put("TANGGAL_AWAL", this.getTanggalAwal());
        map.put("TANGGAL_AKHIR", this.getTanggalAkhir());
        try {
            //JasperCompileManager.compileReportToFile(fileName + "ReportPenjualanByTanggal.jrxml");
            JasperFillManager.fillReportToFile(fileName + "ReportPenjualanByTanggal.jasper", map, koneksi.getConnect());
        //    JasperExportManager.exportReportToPdfFile(fileName + "ReportPenjualanByTanggal.jrprint", tujuan + "Laporan_Penjualan.pdf");
        JasperPrintManager.printReport(fileName + "ReportPenjualanByTanggal.jrprint", true);
        //JasperRunManager.runReportToPdfFile(fileName + "ReportPenjualanByTanggal.jrprint", map, koneksi.getConnect());
        //JasperViewer.viewReport(fileName + "ReportPenjualanByNota.jrprint", false);
        } catch (Exception e1) {
            e1.printStackTrace();
        } finally {
            koneksi.closeConnection();
        }
    }

    public void reportPembelianByTanggal() {
        Map map = new HashMap();
        map.put("TANGGAL_AWAL", this.getTanggalAwal());
        map.put("TANGGAL_AKHIR", this.getTanggalAkhir());
        try {
            //JasperCompileManager.compileReportToFile(fileName + "ReportPembelianByTanggal.jrxml");
            JasperFillManager.fillReportToFile(fileName + "ReportPembelianByTanggal.jasper", map, koneksi.getConnect());
            //JasperExportManager.exportReportToPdfFile(fileName + "ReportPembelianByTanggal.jrprint", tujuan + "Laporan_Pembelian.pdf");
        JasperPrintManager.printReport(fileName + "ReportPembelianByTanggal.jrprint", true);
        //JasperRunManager.runReportToPdfFile(fileName + "ReportPembelianByTanggal.jrprint", map, koneksi.getConnect());
        //JasperViewer.viewReport(fileName + "ReportPembelianByTanggal.jrprint", false);
        } catch (Exception e1) {
            e1.printStackTrace();
        } finally {
            koneksi.closeConnection();
        }
    }

    public void reportPembelianByNotaTunai() {
        Map map = new HashMap();
        map.put("KODE", this.getNoNota());
        try {
            //JasperCompileManager.compileReportToFile(fileName + "ReportPembelianByNotaTunai.jrxml");
            JasperFillManager.fillReportToFile(fileName + "ReportPembelianByNotaTunai.jasper", map, koneksi.getConnect());
            //JasperExportManager.exportReportToPdfFile(fileName+"penjualan.jrprint");
            JasperPrintManager.printReport(fileName + "ReportPembelianByNotaTunai.jrprint", true);
        //JasperRunManager.runReportToPdfFile(fileName + "ReportPenjualanByNota.jrprint", map, Koneksi.getConnect());
        //JasperViewer.viewReport(fileName + "ReportPenjualanByNota.jrprint", false);
        } catch (Exception e1) {
            e1.printStackTrace();
        } finally {
            koneksi.closeConnection();
        }
    }

    public void reportPembelianByNotaKredit() {
        Map map = new HashMap();
        map.put("KODE", this.getNoNota());
        try {
            //JasperCompileManager.compileReportToFile(fileName + "ReportPembelianByNotaKredit.jrxml");
            JasperFillManager.fillReportToFile(fileName + "ReportPembelianByNotaKredit.jasper", map, koneksi.getConnect());
            //JasperExportManager.exportReportToPdfFile(fileName+"penjualan.jrprint");
            JasperPrintManager.printReport(fileName + "ReportPembelianByNotaKredit.jrprint", true);
        //JasperRunManager.runReportToPdfFile(fileName + "ReportPenjualanByNota.jrprint", map, Koneksi.getConnect());
        //JasperViewer.viewReport(fileName + "ReportPenjualanByNota.jrprint", false);
        } catch (Exception e1) {
            e1.printStackTrace();
        } finally {
            koneksi.closeConnection();
        }
    }

    public void reportPiutangByNota() {
        Map map = new HashMap();
        map.put("KODE", this.getNoNota());
        try {
            //JasperCompileManager.compileReportToFile(fileName + "ReportPiutangByNota.jrxml");
            JasperFillManager.fillReportToFile(fileName + "ReportPiutangByNota.jasper", map, koneksi.getConnect());
            //JasperExportManager.exportReportToPdfFile(fileName+"penjualan.jrprint");
            JasperPrintManager.printReport(fileName + "ReportPiutangByNota.jrprint", true);
        //JasperRunManager.runReportToPdfFile(fileName + "ReportPenjualanByNota.jrprint", map, Koneksi.getConnect());
        //JasperViewer.viewReport(fileName + "ReportPenjualanByNota.jrprint", false);
        } catch (Exception e1) {
            e1.printStackTrace();
        } finally {
            koneksi.closeConnection();
        }
    }

    public void reportHutangByNota() {
        Map map = new HashMap();
        map.put("KODE", this.getNoNota());
        try {
            //JasperCompileManager.compileReportToFile(fileName + "ReportHutangByNota.jrxml");
            JasperFillManager.fillReportToFile(fileName + "ReportHutangByNota.jasper", map, koneksi.getConnect());
            //JasperExportManager.exportReportToPdfFile(fileName+"penjualan.jrprint");
            JasperPrintManager.printReport(fileName + "ReportHutangByNota.jrprint", true);
        //JasperRunManager.runReportToPdfFile(fileName + "ReportPenjualanByNota.jrprint", map, Koneksi.getConnect());
        //JasperViewer.viewReport(fileName + "ReportPenjualanByNota.jrprint", false);
        } catch (Exception e1) {
            e1.printStackTrace();
        } finally {
            koneksi.closeConnection();
        }
    }
}
